$(function(){
 
        /*仿刷新：检测是否存在cookie*/
        if($.cookie("captcha")){
            var count = $.cookie("captcha");
            var btn = $('#getting');
            btn.val(count+'秒后可重新获取').attr('disabled',true).css('cursor','not-allowed');
            var resend = setInterval(function(){
                count--;
                if (count > 0){
                    btn.val(count+'秒后可重新获取').attr('disabled',true).css('cursor','not-allowed');
                    $.cookie("captcha", count, {path: '/', expires: (1/86400)*count});
                }else {
                    clearInterval(resend);
                    btn.val("获取验证码").removeClass('disabled').removeAttr('disabled style');
                }
            }, 1000);
        }
 
        /*点击改变按钮状态，已经简略掉ajax发送短信验证的代码*/
        $('#getting').click(function(){
            var btn = $(this);
            var count = 60;
			/* var reg =  /^0?(13[0-9]|15[012356789]|17[0678]|18[0123456789]|14[57])[0-9]{8}$/;
			    if ($(".phone").val() == "") {
			        swal('手机号不能为空');
			        return false;
			    } else if ($(".phone").val().length < 11) {
			        swal('手机号码长度有误');
			        return false;
			    } else if (!reg.test($(".phone").val())) {
			        swal('手机号不存在');} */
            var resend = setInterval(function(){
                count--;
                if (count > 0){
                    btn.val(count+"秒后可重新获取");
                    $.cookie("captcha", count, {path: '/', expires: (1/86400)*count});
                }else {
                    clearInterval(resend);
                    btn.val("获取验证码").removeAttr('disabled style');
                }
            }, 1000);
            btn.attr('disabled',true).css('cursor','not-allowed');
        });
		
    });